package com.shioirikukuri.service.impl;

import com.shioirikukuri.entity.ReservationOrder;
import com.shioirikukuri.mapper.ReservationOrderMapper;
import com.shioirikukuri.service.IReservationOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReservationOrderServiceImpl implements IReservationOrderService {

	@Autowired
	private ReservationOrderMapper reservationOrderMapper;

	@Override
	public List<ReservationOrder> getAllReservationOrders() {
		return reservationOrderMapper.selectAllReservationOrders();
	}

	@Override
	public ReservationOrder getReservationOrderById(Integer orderId) {
		return reservationOrderMapper.selectReservationOrderById(orderId);
	}

	@Override
	public List<ReservationOrder> getReservationOrdersByType(String reservationType) {
		return reservationOrderMapper.selectReservationOrdersByType(reservationType);
	}

	@Override
	public Integer  createReservationOrder(ReservationOrder reservationOrder) {
		reservationOrderMapper.insertReservationOrder(reservationOrder);
		return reservationOrder.getOrderId();
	}

	@Override
	public void updateReservationOrder(ReservationOrder reservationOrder) {
		reservationOrderMapper.updateReservationOrder(reservationOrder);
	}

	@Override
	public void deleteReservationOrderById(Integer orderId) {
		reservationOrderMapper.deleteReservationOrderById(orderId);
	}

	@Override
	public Double getServicePriceByOrderId(Integer orderId) {
		ReservationOrder reservationOrder = reservationOrderMapper.selectReservationOrderById(orderId);
		return reservationOrder.getServiceTotalPrice();
	}
}